//
//  QBDropDownMenuUICalc.swift
//  QBDropDownMenuDemo
//
//  Created by 乐启榜 on 16/7/25.
//  Copyright © 2016年 乐启榜. All rights reserved.
//

import UIKit
import Foundation


/**
 *  主按钮Struct
 */
struct QBDROPDOWNMENU_TITLEBUTTON_UI_VALUE {
    
    var MAINTITLELABEL_FONT: CGFloat = 0.0
    var SUBTITLELABEL_FONT: CGFloat = 0.0
    var SUBTITLELABEL_TOPMARGIN: CGFloat = 0.0
    
    var ARROWVIEW_LEFTMARGIN: CGFloat = 0.0
    var ARROWVIEW_HEIGHT: CGFloat = 0.0
    var ARROWVIEW_WIDTH: CGFloat = 0.0
    
    var BOTTOMLINE_HEIGHT: CGFloat = 0.0
    var BOTTOMSEPERATOR_HEIGHT: CGFloat = 0.0
    var RIGHTSEPERATOR_WIDTH: CGFloat = 0.0
    
    static func titleButtonUIValue() ->(QBDROPDOWNMENU_TITLEBUTTON_UI_VALUE) {
        
        var titleButtonUIValue = QBDROPDOWNMENU_TITLEBUTTON_UI_VALUE()
        
        titleButtonUIValue.MAINTITLELABEL_FONT = 13.0;// 主标题字体大小
        titleButtonUIValue.SUBTITLELABEL_FONT = 12.0;// 子标题子图大小
        titleButtonUIValue.SUBTITLELABEL_TOPMARGIN = 2.5;// 子标题距顶部间距
        titleButtonUIValue.ARROWVIEW_LEFTMARGIN = 3.0;// 箭头距左边边距
        titleButtonUIValue.ARROWVIEW_WIDTH = 6.0;// 箭头宽度
        titleButtonUIValue.ARROWVIEW_HEIGHT = 3.0;// 箭头高度
        titleButtonUIValue.BOTTOMLINE_HEIGHT = 2.0// 底线高度
        titleButtonUIValue.BOTTOMSEPERATOR_HEIGHT = 1.0 // 底线
        titleButtonUIValue.RIGHTSEPERATOR_WIDTH = 1.0; // 右边
        
        return titleButtonUIValue
    }

}

/**
 *  主视图动画时间
 */
struct QBDROPDOWNMENU_MENU_UI_VALUE {
    
    var ANIMATION_DURATION: NSTimeInterval = 0.0
    
    
    static func menuUIValue() ->(QBDROPDOWNMENU_MENU_UI_VALUE) {
        var menuUIVaule = QBDROPDOWNMENU_MENU_UI_VALUE()
        
        menuUIVaule.ANIMATION_DURATION = 0.5
        
        return menuUIVaule
    }

}
/**
 *  集合视图Struct
 */
// 不能理解的地方，为甚不加参数会报错
struct QBDROPDOWNMENU_COLLECTIONVIEW_UI_VALUE {

    var CELL_HEIGHT: CGFloat = 0.0
    var CELL_WIDTH: CGFloat = 0.0
    var LINESPACING: CGFloat = 0.0
    var INTERITEMSPACING: CGFloat = 0.0
    
    var SECTIONINSETS: UIEdgeInsets?
    var ITEMSIZE: CGSize?
    var CELL_LABEL_FONT: CGFloat = 0.0
    var CELL_LABEL_CORNERRADIUS: CGFloat = 0.0
    
    var VIEW_COLUMNCOUNT: NSInteger = 0
    
    var VIEW_TOP_BOTTOM_MARGIN: CGFloat = 0
    var VIEW_LEFT_RIGHT_MARGIN: CGFloat = 0
    
    static func collectionViewUIValue() ->(QBDROPDOWNMENU_COLLECTIONVIEW_UI_VALUE){
        var collectionViewUIValue = QBDROPDOWNMENU_COLLECTIONVIEW_UI_VALUE()
        
        // 每行多少个按钮
        collectionViewUIValue.VIEW_COLUMNCOUNT = 4
        // cell的高度
        collectionViewUIValue.CELL_HEIGHT = 27.0
        // cell行间距
        collectionViewUIValue.LINESPACING = 14.0
        // cell列间距
        collectionViewUIValue.INTERITEMSPACING = 10.0
        // 约束值： 左边/右边
        collectionViewUIValue.VIEW_LEFT_RIGHT_MARGIN = 19.0
        // 约束值： 顶部/底部
        collectionViewUIValue.VIEW_TOP_BOTTOM_MARGIN = 26.0
        // label字体大小
        collectionViewUIValue.CELL_LABEL_FONT = 13.0
        // cell的圆角半径
        collectionViewUIValue.CELL_LABEL_CORNERRADIUS = collectionViewUIValue.CELL_HEIGHT * 0.5
        // cell的宽度： 屏幕宽度 - 左右间距*2 - 列间距*（每行cell个数-1）/ 每行cell的个数
        collectionViewUIValue.CELL_WIDTH = (UIScreen.mainScreen().bounds.size.width - collectionViewUIValue.VIEW_LEFT_RIGHT_MARGIN * 2 - collectionViewUIValue.INTERITEMSPACING * CGFloat(collectionViewUIValue.VIEW_COLUMNCOUNT - 1)) / CGFloat(collectionViewUIValue.VIEW_COLUMNCOUNT)
        // collection边距 上左下右
        collectionViewUIValue.SECTIONINSETS = UIEdgeInsetsMake(collectionViewUIValue.VIEW_TOP_BOTTOM_MARGIN, collectionViewUIValue.VIEW_LEFT_RIGHT_MARGIN, collectionViewUIValue.VIEW_TOP_BOTTOM_MARGIN, collectionViewUIValue.VIEW_LEFT_RIGHT_MARGIN)
        // collectionSize： 宽度 高度
        collectionViewUIValue.ITEMSIZE = CGSizeMake(collectionViewUIValue.CELL_WIDTH, collectionViewUIValue.CELL_HEIGHT);
    
        return collectionViewUIValue
    }
}

func dropDownMenuTitleButtonUIValue() -> (QBDROPDOWNMENU_TITLEBUTTON_UI_VALUE) {
    
    return QBDROPDOWNMENU_TITLEBUTTON_UI_VALUE.titleButtonUIValue()
}

func dropDownMenuMenuUIValue() -> (QBDROPDOWNMENU_MENU_UI_VALUE) {
    return QBDROPDOWNMENU_MENU_UI_VALUE.menuUIValue()
}

func dropDownMenuCollectionViewUIValue() -> QBDROPDOWNMENU_COLLECTIONVIEW_UI_VALUE {
    return QBDROPDOWNMENU_COLLECTIONVIEW_UI_VALUE.collectionViewUIValue()
}

// MARK:-
// MARK:- DeviceWidth&Height
/**
 获取屏幕宽度
 
 - returns: 宽度
 */
func deviceWidth() -> (CGFloat) {
    let width = UIScreen.mainScreen().bounds.size.width
    
    return width
}
/**
 获取屏幕高度
 
 - returns: 高度
 */
func deviceHeight() -> (CGFloat) {
    
    let height = UIScreen.mainScreen().bounds.size.height
    
    return height
}

// MARK:-
// MARK:- Color
func kRGBColorFromHex(rgbValue: Int) -> (UIColor) {
    
    return UIColor(red: ((CGFloat)((rgbValue & 0xFF0000) >> 16)) / 255.0,
                 green: ((CGFloat)((rgbValue & 0xFF00) >> 8)) / 255.0,
                  blue: ((CGFloat)(rgbValue & 0xFF)) / 255.0,
                 alpha: 1.0)
}

func kDropdownMenuTitleColor() -> (UIColor){
    
    return kRGBColorFromHex(0x1D1D26)
    
}

func kDropdownMenuIndicatorColor() -> (UIColor){
    
    return kRGBColorFromHex(0x02C1CD)
    
}

func kDropdownMenuUnselectedCellTextColor() -> (UIColor){
    
    return kRGBColorFromHex(0x1D1D26)
    
    
    
}

func kDropdownMenuSelectedCellColor() -> (UIColor){
    
    return kRGBColorFromHex(0x05CBD8)
    
}

func kDropdownMenuSeperatorColor() -> (UIColor){
    
    return kRGBColorFromHex(0xF3F3F4)
    
}


class QBDropDownMenuUICalc: NSObject {
    
    // 单例
    static var sharedInstance = QBDropDownMenuUICalc()
}













